package probe

import (
	"encoding/csv"
	"os"
	"strconv"
)

var NameItems = make([]string, 0)

var Xtem = make([]float64, 0)
var Xhum = make([]float64, 0)
var Xpre = make([]float64, 0)
var Xlon = make([]float64, 0)
var Xlat = make([]float64, 0)
var Xheight = make([]float64, 0)

func DataClean() {
	//os.OpenFile("", os.O_CREATE|os.O_APPEND|os.O_RDWR, os.ModePerm)
	open, _ := os.Open("/home/fan/IdeaProjects/probe/src/jsonparser/resources/data/ceshi/20180601下午-57461-宜昌-探空仪16070661-质控.csv")
	defer open.Close()
	reader := csv.NewReader(open)
	readAll, _ := reader.ReadAll()
	for _, v := range readAll {
		NameItems = append(NameItems, v[1])
		tem, _ := strconv.ParseFloat(v[2], 64)
		hum, _ := strconv.ParseFloat(v[3], 64)
		pre, _ := strconv.ParseFloat(v[4], 64)
		lon, _ := strconv.ParseFloat(v[5], 64)
		lat, _ := strconv.ParseFloat(v[6], 64)
		height, _ := strconv.ParseFloat(v[7], 64)
		Xtem = append(Xtem, tem)
		Xhum = append(Xhum, hum)
		Xpre = append(Xpre, pre)
		Xlon = append(Xlon, lon)
		Xlat = append(Xlat, lat)
		Xheight = append(Xheight, height)
	}
}
